from fastapi import APIRouter, Request
from app.parameter import CreateHubParam, QueryHubsParam, DeleteHubParam, QueryHubParam
from app.service import HubService, GroupService
from app.utils import getUserInfo

router = APIRouter(tags=["群组路由"])
from utils import DEBUG

# 创建知识库
@router.post("/hub/create")
async def create(createHubParam: CreateHubParam, request: Request):
    DEBUG(createHubParam)
    userId = getUserInfo(request)
    return HubService.createHub(createHubParam, userId)

@router.post("/hub/querys")
async def querys(queryHubParam :QueryHubsParam,request: Request):
    userId = getUserInfo(request)
    return HubService.queryHubs(queryHubParam, userId)

# 解散知识库
@router.post("/hub/delete")
async def delete(deleteHubParam: DeleteHubParam, request: Request):
    DEBUG(deleteHubParam)
    userId = getUserInfo(request)
    return HubService.deleteHub(deleteHubParam, userId)

@router.post("/hub/query")
async def query(queryHubParam: QueryHubParam, request: Request):
    DEBUG(queryHubParam)
    userId = getUserInfo(request)
    return HubService.queryHub(queryHubParam, userId)


